package com.jams.goodox.activity.mine.settings;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.adapter.CustomFragmentPagerAdapter;
import com.jams.goodox.utils.StringUtils;
import com.jams.goodox.utils.StyleUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;


/**
 * 开票设置
 */
public class InvoiceActivity extends BaseActivity {
    @Bind(R.id.tabs_invoice)
    TabLayout tabLayout;
    @Bind(R.id.mPager)
    ViewPager mPager;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_invoice;
    }

    @Override
    protected void init() {
        final String userId = StringUtils.newString(getIntent().getStringExtra("userId"));
        final List<String> tittleList = new ArrayList<>();//标题
        final List<Fragment> contentList = new ArrayList<>();//内容
        contentList.add(InvoiceFragment.newInstance("0", userId));
        contentList.add(InvoiceFragment.newInstance("1", userId));
        tittleList.add(getString(R.string.common_invoice));
        tittleList.add(getString(R.string.added_value_invoice));
        StyleUtil.titleBackKey(this, "开票设置");
        FragmentPagerAdapter adapter = new CustomFragmentPagerAdapter(getSupportFragmentManager(), tittleList, contentList);
        mPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(mPager);
        mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

                
            }

            @Override
            public void onPageSelected(int position) {
                closeKeyboard();
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

    }
}
